$(function () {
  $('.menu-handler').click(function (e) {
    e.preventDefault();
    $(this).toggleClass('active');
    $('#head-drop').toggleClass('active');
  });

  $(".banner").slick({
    autoplay: true,
    arrows: false,
    dots: true,
    infinite: true,
    speed: 1000,
    autoplaySpeed: 5000,
    pauseOnHover: false,
    fade: true,
    cssEase: 'linear'
  });

  var $banner = $(".banner"),
  $bannerItem = $banner.find(".item"),
  $bannerImg = $(".banner .item .pimg");

  function initBanner() {
    if ($(window).width() > 1024) {
      $banner.css({
        height: $(window).height() - 65
      });
      $bannerItem.css({
        height: $(window).height() - 65
      });
    } else {
      $banner.css({
        height: "auto"
      });
      $bannerItem.css({
        height: "auto"
      });
      $bannerImg.attr("style", "").css({
        position: "relative"
      });
    }
  }
  initBanner();
  $(window).resize(function () {
    initBanner();
    initTop();
  });

  function initTop() {
    if ($(window).scrollTop() > 64) {
      $('.right-bar ul .last').show();
    } else {
      $('.right-bar ul .last').hide();
    }
  }

  initTop();

  var timeid = null;
  $(window).scroll(function() {
    if (timeid) timeid = null;
    timeid = this.setTimeout(initTop, 500);
  });

  $('.right-bar ul .last').click(function(e) {
    e.preventDefault();
    $('html, body').stop(false, false).animate({ scrollTop: 0 }, 800, 'easeInOutExpo');
  });
  
  new WOW({
    boxClass: 'wow',
    animateClass: 'animated',
    offset: 0,
    mobile: true,
    live: true
  }).init();

});